define.template({
    type: 'View',
    commands: {
        'save': {
            type: 'Submit',
            src: 'org/save',
            success: '$.alert("保存成功", "br", 3000);VM(this).find($response.data.orgParent).reload();'
        },
        'orgClick': {
            type: 'JS',
            text: 'VM(this).find("display").data("orgId",$0);VM(this).find("display").reload(null,"org/display");'
        },
        'delete': {
            type: 'Confirm',
            text: '您要删除所选择的记录?该操作不可恢复',
            yes: {
                type: 'Ajax',
                src: 'org/delete?orgId=$0',
                success: 'VM(this).find($response.data).remove();VM(this).find("display").template("org/welcome");'
            }
        }
    },
    node: {
        type: 'Horizontal',
        nodes: [
            {
                type: 'Tree',
                template: 'org/nav'
            },
            {
                type: 'Split',
                width: 10,
                movable: true,
                icon: '.i-split-right',
                expandedIcon: '.i-split-left',
                range: '0,400'
            },
            {
                type: 'Vertical',
                width: '*',
                nodes: [
                    {
                        type: 'ButtonBar',
                        align: 'right',
                        nodes: [
                            {
                                text: '新建', on: {
                                    click: 'var display=VM(this).find("display");var orgId=display.data("orgId");' +
                                        'display.data("orgId","");display.data("orgParent",orgId);display.reload(null,"org/display");'
                                }
                            },
                            {type: 'SubmitButton', text: '保存', on: {click: 'this.cmd("save");'}},
                            {text: '删除', on: {click: 'this.cmd("delete",VM(this).find("display").data("orgId"));'}}]
                    },
                    {
                        type: 'Section',
                        id: 'display',
                        height: '*',
                        template: 'org/welcome'
                    }
                ]
            }
        ]
    }
});